package fr.ece.ing4.javafinance.lab1;

import fr.ece.ing4.javafinance.lab1.Bicycle.Type;

class Bicycle {

	public enum Type {
		ROAD("designed for traveling at speed on paved roads."), 
		TOURING("designed for bicycle touring and long journeys."), 
		RACING("designed for speed, and the sport of competitive road racing.");

		String description;

		Type(String description) {
			this.description = description;
		}

		public String toString() {
			return this.name() + " : " + description;
		}
	}

	private static int count = 0;

	private int id;

	private Type type;

	private int cadence;
	private int speed;
	private int gear;

	Bicycle(int startCadence, int startSpeed, int startGear, Type type) {
		this.id = ++count;
		gear = startGear;
		cadence = startCadence;
		speed = startSpeed;
		this.type = type;
	}

	Bicycle() {
		this(0, 0, 1, Type.ROAD);
	}

	void changeCadence(int newValue) {
		cadence = newValue;
	}

	void changeGear(int newValue) {
		gear = newValue;
	}

	void speedUp(int increment) {
		speed = speed + increment;
	}

	void applyBrakes(int decrement) {
		speed = speed - decrement;
	}

	void printStates() {
		System.out.println("Bicycle[" + id + "] (cadence:" + cadence
				+ " speed:" + speed + " gear:" + gear + ") " + type);
	}
}

public class BicycleDemo {
	public static void main(String[] args) {
		Bicycle bike1 = new Bicycle();
		Bicycle bike2 = new Bicycle(30, 0, 8, Type.RACING);

		bike1.changeCadence(50);
		bike1.speedUp(10);
		bike1.changeGear(2);
		bike1.printStates();

		bike2.changeCadence(50);
		bike2.speedUp(10);
		bike2.changeGear(2);
		bike2.changeCadence(40);
		bike2.speedUp(10);
		bike2.changeGear(3);
		bike2.printStates();
	}
}
